"""
Minimal test of RadianceBUFRReader
"""

println("Starting radiance BUFR reader test...")

# Add to load path
push!(LOAD_PATH, dirname(@__DIR__) * "/src")

println("Loading modules...")
using GSICoreAnalysis
using GSICoreAnalysis.DataIO
using GSICoreAnalysis.DataIO.RadianceBUFRReader

println("Module loaded successfully!")

# Test file
const AMSUA_FILE = "/home/docker/comgsi/tutorial/case_data/2018081212/obs/gdas1.t12z.1bamua.tm00.bufr_d"

println("\nReading AMSU-A file: $AMSUA_FILE")

# Read with small limit for quick test
config = RadianceBUFRConfig(verbose=true, max_obs=100)
radiance_obs = read_radiance_bufr(AMSUA_FILE; config=config)

println("\n" * "="^60)
println("SUCCESS! RadianceBUFRReader is working!")
println("="^60)
println("\nObservation Summary:")
println("  Satellite: $(radiance_obs.satellite_id)")
println("  Instrument: $(radiance_obs.instrument)")
println("  Channels: $(radiance_obs.channels)")
println("  Number of observations: $(size(radiance_obs.brightness_temp, 2))")
println("  Brightness temp range: $(round(minimum(radiance_obs.brightness_temp), digits=1))K to $(round(maximum(radiance_obs.brightness_temp), digits=1))K")
println("  Latitude range: $(round(minimum(radiance_obs.latitude), digits=1))° to $(round(maximum(radiance_obs.latitude), digits=1))°")
println("  Longitude range: $(round(minimum(radiance_obs.longitude), digits=1))° to $(round(maximum(radiance_obs.longitude), digits=1))°")
println("\nData types (for CRTM compatibility):")
println("  brightness_temp: $(eltype(radiance_obs.brightness_temp))")
println("  channels: $(eltype(radiance_obs.channels))")
println("  zenith_angle: $(eltype(radiance_obs.zenith_angle))")
println("\nData layout (column-major for Fortran):")
println("  brightness_temp size: $(size(radiance_obs.brightness_temp)) (channels × observations)")
println("="^60)
